/*++

 Copyright (c) Microsoft Corporation. 
 
 This source code is subject to terms and conditions of the Microsoft
 Public License. A copy of the license can be found in the License.txt
 file at the root of this distribution. By using this source code in 
 any fashion, you are agreeing to be bound by the terms of the Microsoft
 Public License.
 
 You must not remove this notice, or any other, from this software.

Module Name:

    Device.h

Abstract:

    This module contains the type definitions for the Generic Serial
    driver's device callback class.

--*/

#pragma once

#include "sensorsclassextension.h"
#include "SensorBaseDriver.h"

//class SensorBaseDriver;

class ATL_NO_VTABLE CMyDevice :
    public CComObjectRootEx<CComMultiThreadModel>,
    public IPnpCallbackHardware,
    public IFileCallbackCleanup
{
public:
    ~CMyDevice();

    DECLARE_NOT_AGGREGATABLE(CMyDevice)

    BEGIN_COM_MAP(CMyDevice)
        COM_INTERFACE_ENTRY(IPnpCallbackHardware)
        COM_INTERFACE_ENTRY(IFileCallbackCleanup)
    END_COM_MAP()

protected:
    CMyDevice();

    HRESULT ConfigureQueue();

// COM Interface methods
public:

    //
    // IPnpCallbackHardware
    //
    STDMETHOD_ (HRESULT, OnPrepareHardware)(__in IWDFDevice* pWdfDevice);
    STDMETHOD_ (HRESULT, OnReleaseHardware)(__in IWDFDevice* pWdfDevice);
    //
    // IFileCallbackCleanup
    //
    STDMETHOD_ (VOID, OnCleanupFile)(__in IWDFFile *pWdfFile);

public:

    // The factory method used to create an instance of this device
    static HRESULT CreateInstance(__in IWDFDriver* pDriver, __in IWDFDeviceInitialize*  pDeviceInit);

    HRESULT ProcessIoControl(__in IWDFIoQueue*     pQueue,
                             __in IWDFIoRequest*   pRequest,
                             __in ULONG            ControlCode,
                                  SIZE_T           InputBufferSizeInBytes,
                                  SIZE_T           OutputBufferSizeInBytes,
                                  DWORD*           pcbWritten);
private:

    CComPtr<IWDFDevice>     m_pWdfDevice;
    ISensorClassExtension*  m_pClassExtension;

    //BUGBUG Verify that this works
    CComPtr<SensorBaseDriver>   m_pSBaseDriver;
    //static SensorBaseDriver*       m_pSBaseDriver; 

};

